﻿//-----------------------------------------------------------------------
// <copyright file="IBuildProjectNodeComparer.cs">(c) http://TfsBuildExtensions.codeplex.com/. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved.</copyright>
//-----------------------------------------------------------------------
namespace TfsBuildExtensions.Activities.TeamFoundationServer
{
    using System.Collections.Generic;
    using Microsoft.TeamFoundation.Build.Client;

    /// <summary>
    /// Enables sorting of IBuildProjectNode's
    /// </summary>
    class IBuildProjectNodeComparer : IEqualityComparer<IBuildProjectNode>
    {
        /// <summary>
        /// Equals on ServerPath
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public bool Equals(IBuildProjectNode x, IBuildProjectNode y)
        {
            return (x.ServerPath.Equals(y.ServerPath));
        }

        /// <summary>
        /// ´Returns hashcode for serverpath
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int GetHashCode(IBuildProjectNode obj)
        {
            return obj.ServerPath.GetHashCode();
        }
    }
}
